package com.nyt.org.modules.login;

import com.nyt.org.common.utils.SendPostRequest;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class ConductorLoginService {

    public static void main(String[] args) {

        Document document;
        //建立标签名为root的根部标签
        Element root = DocumentHelper.createElement("ROOT");
        document = DocumentHelper.createDocument(root);
        /*
         * 拼接head
         * */
        Element head = root.addElement("HEAD");
        Element App = head.addElement("App");
        App.setText("南粤通-测试");//应用名称
        Element Ver = head.addElement("Ver");
        Ver.setText("2.0");//版本号
        Element MsgID = head.addElement("MsgID");
        MsgID.setText("test");//报文标识号
        Element MsgCode = head.addElement("MsgCode");
        MsgCode.setText("202001");//交易代码
        Element SellWay = head.addElement("SellWay");
        SellWay.setText("0000");//销售渠道 Web 销 售 (0000),POS 销 售(0001)
        Element AppKey = head.addElement("AppKey");
        AppKey.setText("F7466F863A986EC53FED570124478997");//接入 Key  系统分配授权代码
        Element AppSecret = head.addElement("AppSecret");
        AppSecret.setText("225CC17E1C30CD62");//接入密码 系统分配授权密码
        Element OperID = head.addElement("OperID");
        OperID.setText("publicTst");//操作员
        Element BranchID = head.addElement("BranchID");
        BranchID.setText("999009");//机构号
        /**
         * 拼接body
         * 注：报文 body 内不传递任何参数即返回全量城市站点数据；
         * */
        Element bodyXml = root.addElement("BODY");
        Element REQ2001 = bodyXml.addElement("REQ2001");
        //仅获取城市 传递 Y 仅获取城市数据
        Element GetCityOnly = REQ2001.addElement("LoginName");
        GetCityOnly.setText("publicTst");
        //获取动态站点  传递 Y 获取动态城市站点数据
        Element DynamicSite = REQ2001.addElement("Password");
        DynamicSite.setText("000000");

        String xml = document.asXML();

        System.out.println("=====");
        System.out.println(xml);

        //发送请求 http://test.hkcts.hebuyun.com:9090/tsp/

        String url = "http://test.hkcts.hebuyun.com:9090/tsp/";

        String str = SendPostRequest.doPost(url,xml);
        System.out.println(str);

    }



}
